Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Right - I am basically making a materia mod with a levelling item that gives you a spell. Quoted Below Is my Current Script. Which Doesn't Work.
Quote:
Begin WEW_restoremateria_script
short OnPCEquip
short RestoreMateriaAP
if ( OnPCEquip == 1 )
MessageBox "You Equipped Restore Materia!"
Player -> AddSpell "WEW_Cure1"
set OnPCEquip to 2
endif
if ( OnPCEquip == 0 )
Player -> RemoveSpell "WEW_Cure1"
endif
if ( RestoreMateriaAP == 500 )
MessageBox "Restore Materia Has Levelled Up!"
Player -> AddItem "WEW_RestoreMateria2", 1
set RestoreMateriaAP to 0
endif
if ( OnPCEquip = 2 )
if ( mudcrab -> Health < 1 )
MessageBox "You Killed Mudcrab: 250Ap"
set RestoreMateriaAP to RestoreMateriaAP + 250
endif
endif
End
I originally used an OnDeath function rather than the health check - however OnDeath doesn't work for Non-Unique creatures, right? (Correct Me If I'm Wrong With This)
The Error Message I recieve Is When I equip the materia and... I Can't remember the actual content of the message (though I can go check if you wish) The part I DO remember of the message was one word... in full caps: EXPRESSION
I had similar script working (sort of) with an NPC (Eldafire) using the OnDeath function rather than the health check.
However - OnDeath doesn't seem to work - neither does this. Sorry For Sounding Dumb - But I'm New Too Scripting ^-^
If THis is a simple thing than could you also turn your hand to this problem... if the object (wew_restoremateria(it's a ring)) is not equipped when the kill is made than it still recieves the EXP when it is equipped later on - which I don't want, perhaps you can help me?Sorry if I sound unclear....
Anyway - Any help would be MUCH appreciated.
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
TheSlof
|
Curate
|
|
|
Reged: 03/16/04
|
Posts: 425
|
Loc: Trollhättan, Sweden
|
|
|
Begin WEW_restoremateria_script
short OnPCEquip short RestoreMateriaAP
if ( OnPCEquip == 1 ) MessageBox "You Equipped Restore Materia!" Player -> AddSpell "WEW_Cure1" set OnPCEquip to 2 endif
if ( OnPCEquip == 0 ) Player -> RemoveSpell "WEW_Cure1" endif
if ( RestoreMateriaAP == 500 ) MessageBox "Restore Materia Has Levelled Up!" Player -> AddItem "WEW_RestoreMateria2", 1 set RestoreMateriaAP to 0 endif
if ( OnPCEquip = 2 ) if ( mudcrab -> Health < 1 ) MessageBox "You Killed Mudcrab: 250Ap" set RestoreMateriaAP to RestoreMateriaAP + 250 endif endif
End
Ok.. I tabbed the script to make it easy to understand,.
First: "if ( mudcrab -> Health < 1 )" should be "if ( mudcrab->GetHealth < 1 )" (and skip the spaces before and after the "->". They tend to cause problems) Second: There's a command that keeps track of how many creatures you have killed.. Check out Morrowind Scripting For Dummies for more info.
-------------------- My tutorials:
Here or here!
||||||
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Thanks ^-^
0_0 Sorry about the spaces around the fix - I guess I got confused because that's how it is laid out in scripting for dummies.
I'll give that code a try and will be back - if it doesn't work.
Thanks alot
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Hrm...
Well The situation has improved - I no longer get an error message. However...
The variable "RestoreMateriaAP" isn't increasing when I kill Mudcrabs - whether the materia is equipped or not
Also The message is not appearing
-------------------- She said she'll be back when it's all over... Those were her last words.
Edited by Wyver (08/14/04 07:44 PM)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Hrm... I'm guessing that my problem is that Mudcrab are not unique. So my script applies only to a single mudcrab in the world... or rather, in the cell I occupy and all four adjacent cells... right?
So the killing mudcrab00000001 would result in a message but mudcrab00000004 would not, correct?
If that is the case... does anyone have, perhaps, a solution?
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
This is because you want this line: if ( mudcrab -> GetHealth <= 0 )
I'm actually not quite sure that this will work how you want either.
I would suggest something like this for keeping track of killing mudcrabs:
short crabsDead
if ( getDeadCount, "mudcrab" > crabsDead ) set crabsDead to getDeadCount, "mudcrab" ;every time this if block returns true, another mudcrab has been killed, so increment your xp in here endif
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Ah - but I only want to increase the item's exp when it is equipped. Would that code not increase it at all times?
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 05/31/00
|
Posts: 6115
|
Loc: Long Beach, CA, USA
|
|
|
None of the "->" commands work wioth non-unique creatures. So about about this:
Code:
Begin WEW_restoremateria_script
short OnPCEquip short RestoreMateriaAP short KilledCount
if ( OnPCEquip == 1 ) MessageBox "You Equipped Restore Materia!" Player -> AddSpell "WEW_Cure1" set OnPCEquip to 2 set KilledCount to GetDeadCount Mudcrab endif
if ( OnPCEquip == 0 ) Player -> RemoveSpell "WEW_Cure1" endif
if ( RestoreMateriaAP == 500 ) MessageBox "Restore Materia Has Levelled Up!" Player -> AddItem "WEW_RestoreMateria2", 1 set RestoreMateriaAP to 0 endif
if ( OnPCEquip == 2 ) ;changed = to == if ( GetDeadCount Mudcrab > KilledCount ) set KilledCount to GetDeadCount Mudcrab MessageBox "You Killed Mudcrab: 250Ap" set RestoreMateriaAP to RestoreMateriaAP + 250 endif endif
End
Still untested though. Good luck.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
Yeah, if you just use what I wrote lol. I meant you could insert those lines into your script at the appropriate places.
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Ha. Wow. ^-^ Thanks for the help you two. You've no idea how motivating it is knowing that there is a community here to help me out when I get stuck. Thanks.
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
Quote:
You've no idea how motivating it is knowing that there is a community here to help me out when I get stuck.
Hear, hear. I can usually solve most of my own problems now, but I doubt I'd still be scripting/modding without the support and aid of the people on this forum.
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Ok. Here is my amended Code... however - I found a bug
Quote:
Begin WEW_restoremateria_script
Short OnPCEquip Short RestoreMateriaAP Short KillCountMudcrab
if ( OnPCEquip == 1 ) MessageBox "You Equipped Restore Materia!" Player->AddSpell "WEW_Cure1" set OnPCEquip to 2 set KillCountMudcrab to GetDeadCount Mudcrab endif
if ( OnPCEquip == 0 ) if Player->RemoveSpell "WEW_Cure1" endif
if ( RestoreMateriaAP == 500 ) MessageBox "Restore Materia Has Levelled Up!" Player->AddItem "WEW_RestoreMateria2", 1 set RestoreMateriaAP to 0 endif
if ( OnPCEquip == 2 ) if ( GetDeadCount Mudcrab > KillCountMudcrab ) set KillCountMudcrab to GetDeadCount Mudcrab MessageBox "You Killed Mudcrab: 250Ap" set RestoreMateriaAP to RestoreMateriaAP + 250 endif endif
End
Say, you had TWO of this item and you equipped both. If you unequip one it will remove the spell - even though you still have one equipped that means that you should have the spell.
I have thought of a way round it - detect whether the PC had the spell already when the materia is equipped. If the PC does then (s)he must already have one of the items equipped as the spell is not for sale anywhere and can only be gotten by having the item equipped (or using the console). Anyway - if they already have the spell then set a variable (NoRemove) to equal 1 and don't add the spell - when they later remove one of the items check to see if NoRemove equals 1 - if it does - do not remove the spell.
However... I don't know how to check if the PC has the spell or not...
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
How about using Player -> HasItemEquipped instead of OnPCEquip?
I haven't tested this, but it looks ok to me:
Code:
Begin WEW_restoremateria_script
Short OnPCEquip Short RestoreMateriaAP Short KillCountMudcrab Short spellControl
if ( Player -> HasItemEquipped, "item_ID" == 1 ) if ( spellControl == 0 ) MessageBox "You Equipped Restore Materia!" Player->AddSpell "WEW_Cure1" set KillCountMudcrab to GetDeadCount Mudcrab set spellControl to 1 endif else if ( player -> GetSpellEffects, "WEW_Cure1" ) Player->RemoveSpell "WEW_Cure1" set spellControl to 0 endif endif
if ( RestoreMateriaAP == 500 ) MessageBox "Restore Materia Has Levelled Up!" Player->AddItem "WEW_RestoreMateria2", 1 set RestoreMateriaAP to 0 endif
if ( spellControl == 1 ) if ( GetDeadCount Mudcrab > KillCountMudcrab ) set KillCountMudcrab to GetDeadCount Mudcrab MessageBox "You Killed Mudcrab: 250Ap" set RestoreMateriaAP to RestoreMateriaAP + 250 endif endif
End
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
^-^
Thanks. I'll Go Give It A Try.
P.S. You've moved up a spot in the readme
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
Quote:
P.S. You've moved up a spot in the readme
Lol, thanks... that's why I help people on the forum.
P.S. Not really.
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Ok - My Code Has Evolved...
Quote:
Begin WEW_restoremateria_script
Short OnPCEquip Short RestoreMateriaAP Short KillCountMudcrab
if ( OnPcEquip == 1 ) MessageBox "You Equipped Restore Materia!" Player->AddSpell wew_cure1 set KillCountMudcrab to GetDeadCount Mudcrab set OnPcEquip to 2 endif elseif ( OnPcEquip == 0 ) if ( Player->HasItemEquipped wew_restoremateria4 == 0 ) if ( Player->HasItemEquipped wew_restoremateria3 == 0 ) if ( Player->HasItemEquipped wew_restoremateria2 == 0 ) if ( Player->HasItemEquipped wew_restoremateria == 0 ) Player->RemoveSpell wew_cure1 endif endif endif endif endif
if ( RestoreMateriaAP >= 500 ) MessageBox "Restore Materia Has Levelled Up!" Player->AddItem "WEW_RestoreMateria2", 1 set RestoreMateriaAP to 0 endif
if ( OnPcEquip == 2 ) if ( GetDeadCount Mudcrab > KillCountMudcrab ) set KillCountMudcrab to GetDeadCount Mudcrab MessageBox "You Killed Mudcrab: 251Ap" set RestoreMateriaAP to RestoreMateriaAP + 251 endif endif
End
The problem is... It all seems to wrk fine... but if you equip two of this item and then unequip one, they will both be unequipped... any idea why?
And wew_restoremateria is the ID of the item that this is attached to the others (wew_restoremateria2, wew_restoremateria3, etc) are levelled versions which also add the spell wew_Cure1
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
I'm not sure why you're having that problem with de-equipping, but my guess would be that it has to do with your use of OnPCEquip. Why don't you try dispensing with it altogether, as I suggested earlier, and just use HasItemEquipped?
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Quote:
Why don't you try dispensing with it altogether, as I suggested earlier, and just use HasItemEquipped
Ok. I'll give that a shot... I did use that at one point... but I dropped it for some reason that I forget ^-^
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Ah... That was why.
The 'You Equipped Restore Materia!', message never goes away with HasItemEquipped... I think I could just whack in a simple control variable to stop that though.
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Hrm...
Would You look at that...
Quote:
if ( OnPcEquip == 1 ) MessageBox "You Equipped Restore Materia!" Player->AddSpell wew_cure1 set KillCountMudcrab to GetDeadCount Mudcrab set OnPcEquip to 2 endif elseif ( OnPcEquip == 0 ) if ( Player->HasItemEquipped wew_restoremateria4 == 0 ) if ( Player->HasItemEquipped wew_restoremateria3 == 0 ) if ( Player->HasItemEquipped wew_restoremateria2 == 0 ) if ( Player->HasItemEquipped wew_restoremateria == 0 ) Player->RemoveSpell wew_cure1 endif endif endif endif endif
Now I feel stupid
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Curiouser and curiouser...
removing that endif only makes things worse! Without that you can't even equip two materia!
I'll just change that elseif to an if
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
Try completely getting rid of all the uses of OnPCEquip. Make a new control variable to make sure things only get done once. I'm pretty sure that's where your problem is.
Also, when you post code, if you use the code tags instead of quote tabs, it preserves your tabs, which makes it much easier to read.
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
Wyver
|
Initiate
|
|
|
Reged: 08/07/04
|
Posts: 73
|
|
|
|
Ok. I'll do that from now on - I Have A question though... Why USe HasItemEquipped over OnPcEquip? I'm sorry if that sounded rude, because I certainly didn't mean it that way...
-------------------- She said she'll be back when it's all over... Those were her last words.
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
Well, if you want to add a bonus when only one of a possible two items is equipped, HasItemEquipped will make it a lot easier to see when one is equipped. Second, I think it's just a personal prejudice; I've only tried using OnPCEquip a couple of times, and I had problems that I solved by switching to HasItemEquipped in every instance.
Those are my reasons. You can do it any way, you want, of course.
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|